#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
int n,m,head[410],cnt,idx[410],S,T;
struct edge
{
	int v,next,val;
}e[100010];
void addedge(int x,int y,int z)
{
	e[cnt]=(edge){y,head[x],z};
	head[x]=cnt++;
	return;
}
void bfs()
{
	memset(idx,0,sizeof(idx));
	queue<int>q;
	q.push(S);
	idx[S]=1;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=head[u];~i;i=e[i].next)
		{
			int v=e[i].v;
			if(idx[v]||!e[i].val)continue;
			idx[v]=idx[u]+1;
			q.push(v);
		}
	}
	return;
}
int dfs(int u,int _min)
{
	if(u==T)return _min;
	int ret=0,k;
	for(int i=head[u];~i;i=e[i].next)
	{
		int v=e[i].v;
		if(idx[v]!=idx[u]+1||!e[i].val)continue;
		k=dfs(v,min(_min-ret,e[i].val));
		e[i].val-=k;
		e[i^1].val+=k;
		ret+=k;
		if(ret==_min)break;
	}
	return ret;
}
int dinic()
{
	int ret=0;
	while(true)
	{
		bfs();
		if(!idx[T])break;
		ret+=dfs(S,INF);
	}
	return ret;
}
int main()
{
	memset(head,-1,sizeof(head));
	scanf("%d%d",&n,&m);
	S=0;T=n*2+1;
	int temp;
	scanf("%d",&temp);
	addedge(S,temp,INF);
	addedge(temp,S,0);
	scanf("%d",&temp);
	addedge(temp+n,T,INF);
	addedge(T,temp+n,0);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&temp);
		addedge(i,i+n,temp);
		addedge(i+n,i,0);
	}
	while(m--)
	{
		int t1,t2;
		scanf("%d%d",&t1,&t2);
		addedge(t1+n,t2,INF);
		addedge(t2,t1+n,0);
		addedge(t2+n,t1,INF);
		addedge(t1,t2+n,0);
	}
	printf("%d\n",dinic());
	return 0;
}
